package com.yiku.controller;

import com.yiku.common.APIResultDTO;
import com.yiku.common.enums.CommonMessageEnum;
import com.yiku.service.U9CloudService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author:ludada
 * @Date:2024/02/22 09:43
 */
@Api(tags = "token")
@RestController
public class TokenController extends BaseController{
    @Autowired
    U9CloudService u9CloudService;

    @ApiOperation("获取token")
    @GetMapping("/getToken")
    public void getToken(HttpServletResponse response){
        APIResultDTO<String> token = u9CloudService.getToken();
        if(token.isFlag()){
            this.sendJsonSuccess(CommonMessageEnum.SUCCESS.getMsg(), CommonMessageEnum.SUCCESS.getCode(),token.getData() , response);
        }else{
            this.sendJsonError(CommonMessageEnum.FAIL.getMsg(), CommonMessageEnum.FAIL .getCode(), response);
        }

    }
}
